package com.huawei.appmarket.service.usercenter.userinfo.view.activity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import o.azb;
import o.der.b;
import o.der.g;
import o.Logger;
import o.ContentManager;
import o.emf;
import o.eqp;

public class ChooseCountryAdapter extends BaseAdapter {
    public static final int CHOOSE_COUNTRY_CELL_LINE_TYPE = 2;
    public static final int CHOOSE_COUNTRY_CONTENT_TYPE = 1;
    public static final int CHOOSE_COUNTRY_LETTER_TYPE = 0;
    private static final String TAG = "ChooseCountryAdapter";
    private static final int TYPE_COUNTRY = 3;
    private ArrayList<emf> countryPhoneList = new ArrayList();
    private Context mContext;

    static class a {
        TextView ˊ = null;

        a() {
        }
    }

    static class d {
        TextView ˋ = null;
        TextView ॱ = null;

        d() {
        }
    }

    public ChooseCountryAdapter(Context context, List<emf> list) {
        this.mContext = context;
        this.countryPhoneList.addAll(list);
    }

    public void updateList(List<emf> list) {
        this.countryPhoneList.clear();
        if (list != null) {
            this.countryPhoneList.addAll(list);
        }
        notifyDataSetChanged();
    }

    public int getCount() {
        if (this.countryPhoneList != null) {
            return this.countryPhoneList.size();
        }
        return 0;
    }

    public emf getItem(int i) {
        if (i < 0 || i >= this.countryPhoneList.size()) {
            return null;
        }
        return (emf) this.countryPhoneList.get(i);
    }

    public long getItemId(int i) {
        return 0;
    }

    public int getViewTypeCount() {
        return 3;
    }

    public int getItemViewType(int i) {
        if (i < 0 || i >= this.countryPhoneList.size()) {
            return 0;
        }
        return ((emf) this.countryPhoneList.get(i)).ˎ();
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        d dVar = null;
        if (i >= 0 && i < this.countryPhoneList.size()) {
            a aVar;
            emf o_emf = (emf) this.countryPhoneList.get(i);
            int ˎ = o_emf.ˎ();
            if (view == null) {
                if (ˎ == 2) {
                    view = LayoutInflater.from(this.mContext).inflate(g.ˊˊ, null);
                    aVar = null;
                } else if (ˎ == 0) {
                    a aVar2 = new a();
                    view = LayoutInflater.from(this.mContext).inflate(g.ˊˋ, null);
                    aVar2.ˊ = (TextView) view.findViewById(o.der.d.ॱᶥ);
                    view.setTag(aVar2);
                    aVar = aVar2;
                } else if (ˎ == 1) {
                    d dVar2 = new d();
                    view = LayoutInflater.from(this.mContext).inflate(g.ˊᐝ, null);
                    dVar2.ˋ = (TextView) view.findViewById(o.der.d.ʼˋ);
                    dVar2.ॱ = (TextView) view.findViewById(o.der.d.ʽˊ);
                    view.setTag(dVar2);
                    aVar = null;
                    dVar = dVar2;
                } else {
                    Logger.ˎ(TAG, "no such type");
                    aVar = null;
                }
            } else if (ˎ == 0) {
                aVar = (a) view.getTag();
            } else if (ˎ == 1) {
                dVar = (d) view.getTag();
                Object obj = null;
            } else {
                aVar = null;
            }
            adapterRing(view, dVar, aVar);
            initViewHolder(dVar, aVar, i, o_emf);
        }
        return view;
    }

    private void initViewHolder(d dVar, a aVar, int i, emf o_emf) {
        if (dVar != null) {
            CharSequence ˊ = eqp.ˊ(o_emf.ˋ());
            CharSequence ॱ = o_emf.ॱ();
            dVar.ˋ.setText(ˊ);
            dVar.ॱ.setText(ॱ);
        } else if (aVar != null) {
            aVar.ˊ.setText(((emf) this.countryPhoneList.get(i)).ˊ());
        }
    }

    private void adapterRing(View view, d dVar, a aVar) {
        Context ˋ = ContentManager.getInstant().getContext();
        if (azb.ʼ(ˋ)) {
            if (aVar != null) {
                azb.ˋ(aVar.ˊ);
            } else if (dVar != null) {
                azb.ॱ(view.findViewById(o.der.d.ʾॱ));
                azb.ʻ(view.findViewById(o.der.d.ꓸ));
            }
        } else if (aVar != null) {
            azb.ˋ(aVar.ˊ, ˋ.getResources().getDimensionPixelOffset(b.ʼ), ˋ.getResources().getDimensionPixelOffset(b.ʻ));
        } else if (dVar != null) {
            azb.ʼ(view.findViewById(o.der.d.ʾॱ), ˋ.getResources().getDimensionPixelOffset(b.ʼ));
            azb.ॱॱ(view.findViewById(o.der.d.ꓸ), ˋ.getResources().getDimensionPixelOffset(b.ʻ));
        }
    }
}
